#![feature(impl_trait_in_assoc_type)]
use std::pin::Pin;
use std::{rc::Rc, sync::Arc};

use std::future::Future;

type BoxFuture<T> = Pin<Box<dyn Future<Output = T>>>;

use futures_util::future::{ok, ready};

trait PointerFamily {
    type PointerType<T>;
}

struct RcPointer;

impl PointerFamily for RcPointer {
    type PointerType<T> = Rc<T>;
}

struct ArcPointer;

impl PointerFamily for ArcPointer {
    type PointerType<T> = Arc<T>;
}

struct MyDataStructure<T, PointerSel: PointerFamily> {
    data: PointerSel::PointerType<T>,
}

#[derive(Debug, Clone)]
struct Request<'l>(&'l str);

trait FromRequest<'b>: Sized {
    type Future<'a>: Future<Output = Result<Self, anyhow::Error>>
    where
        Self: 'a;
    fn from_request<'a>(s: Request<'b>) -> Self::Future<'a>;
}

impl<'b> FromRequest<'b> for Request<'b> {
    type Future<'a> = impl Future<Output = Result<Request<'b>, anyhow::Error>>
    where Self: 'a;
    fn from_request<'a>(s: Request<'b>) -> Self::Future<'a> {
        ok(s)
    }
}

#[tokio::main]
async fn main() {
    let s = "NiHao";
    let req = Request::from_request(Request(s)).await;
    println!("{req:?}");
    let a = MyDataStructure::<_, ArcPointer> {
        data: Arc::new(123),
    };
}
